﻿using System;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;

using Telerik.WebControls;
using UFSoft.UBF.UI.WebControls;
using UFSoft.UBF.UI.Controls;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.Util.Globalization;

using UFSoft.UBF.UI.IView;
using UFSoft.UBF.UI.Engine;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.UI.WebControls.ClientCallBack;



/***********************************************************************************************
 * Form ID: 
 * UIFactory Auto Generator 
 ***********************************************************************************************/
namespace POShipLineRef
{
    public partial class POShipLineRefWebPart
    {
        #region Custome eventBind
        public override bool UseQueryCase
        {

            get { return true; }

        }


        //FindButton_Click...
        private void FindButton_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			FindButton_Click_DefaultImpl(sender,e);
		}	
		 
				//QryButton_Click...
		private void QryButton_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			QryButton_Click_DefaultImpl(sender,e);
		}	
		 

			

		//DDLCase_TextChanged...
		private void DDLCase_TextChanged_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			DDLCase_TextChanged_DefaultImpl(sender,e);
		}	
		 
				//ConfirmButton_Click...
		private void ConfirmButton_Click_Extend(object sender, EventArgs  e)
		{
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.

            CreateDeliveDoc();

            ConfirmButton_Click_DefaultImpl(sender,e);
		}	
		 
				//CancelButton_Click...
		private void CancelButton_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			
		
			CancelButton_Click_DefaultImpl(sender,e);
		}	
		 
			
				

		//DataGrid_GridRowDbClicked...
		private void DataGrid_GridRowDbClicked_Extend(object sender, GridDBClickEventArgs  e)
		{
            //调用模版提供的默认实现.--默认实现可能会调用相应的Action.
            CreateDeliveDoc();

            DataGrid_GridRowDbClicked_DefaultImpl(sender,e);
		}

		private void CreateDeliveDoc()
        {
            this.Model.ClearErrorMessage();
            UFIDA.U9.Cust.U9Demo.DeliveryBP.Proxy.CreateDocFromPOProxy proxy = new UFIDA.U9.Cust.U9Demo.DeliveryBP.Proxy.CreateDocFromPOProxy();
            proxy.POShipLineList = new System.Collections.Generic.List<string>();
            foreach (IUIRecord record in this.Model.cRef.Cache.GetSelectRecord())
            {
                if (!proxy.POShipLineList.Contains(record["ID"].ToString()))
                {
                    proxy.POShipLineList.Add(record["ID"].ToString());
                }
            }
            if (proxy.POShipLineList.Count == 0)
                throw new Exception("请选择行数据");
            if (this.CurrentState["DucumentTypeID"] != null)
            {
                proxy.DocumentType = Convert.ToInt64(this.CurrentState["DucumentTypeID"].ToString());
            }
            long deliveryID = proxy.Do();
            if (deliveryID > 0)
            {
                this.CurrentState["DeliveryID"] = deliveryID;
                this.CloseDialog(true);
            }
        }
            
            
            
            

		#region 自定义数据初始化加载和数据收集
		private void OnLoadData_Extend(object sender)
		{	
			OnLoadData_DefaultImpl(sender);
		}
		private void OnDataCollect_Extend(object sender)
		{	
			OnDataCollect_DefaultImpl(sender);
		}
		#endregion  

        #region 自己扩展 Extended Event handler 
		public void AfterOnLoad()
		{

		}

        public void AfterCreateChildControls()
        {


		
        }
        
        public void AfterEventBind()
        {
        }
        
		public void BeforeUIModelBinding()
		{

		}

		public void AfterUIModelBinding()
		{


		}


        #endregion
		
        #endregion
		
    }
}